/*
 * @Autor: Hongting Yuan
 * @Date: 2021-12-07 08:34:08
 * @LastEditors: Ruohong Yu
 * @LastEditTime: 2021-12-13 14:20:44
 * @Description: file content
 * @FilePath: \mimalld:\桌面\作业\软件工程\前端\front_regit\src\router\index.js
 */
import Vue from 'vue'
import VueRouter from 'vue-router'
import LoginPlus from '../views/LoginPlus.vue'
import crypto from '../crypto/crypto'
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
// import common from '../views/common.vue'
Vue.use(VueRouter)

var mpath = []
for (var i = 1; i < 70; i++) {
  mpath[i] = crypto.set(i)
}

const routes = [
  {
    path: '/',
    name: 'loginplus',
    component: LoginPlus
  },
  {
    path: '/home/:key',
    name: 'Home',
    redirect: '/' + mpath[2],
    meta: { permission: true },
    beforeEnter: function(to, from, next) {
      if (sessionStorage.getItem('token')) {
        next()
      } else {
        this.$message.info('请先登录')
        next('/')
      }
    },
    component: () => import(/* webpackChunkName: "about" */ '../views/Home.vue'),
    children: [
      { path: '/' + mpath[2], name: 'WorkPlace', component: () => import(/* webpackChunkName: "about" */ '../views/myproject/WorkPlace.vue') },
      { path: '/' + mpath[47], component: () => import(/* webpackChunkName: "about" */ '../views/myproject/LargeDataScreen.vue') },
      { path: '/' + mpath[4], component: () => import(/* webpackChunkName: "about" */ '../views/kyproject/Apply.vue') },
      { path: '/' + mpath[5], name: 'EndApply', component: () => import(/* webpackChunkName: "about" */ '../views/kyproject/EndApply.vue') },
      { path: '/' + mpath[31], name: 'PaperEnd', component: () => import(/* webpackChunkName: "about" */ '../views/kyproject/PaperEnd.vue') },
      { path: '/' + mpath[32], name: 'AwardEnd', component: () => import(/* webpackChunkName: "about" */ '../views/kyproject/AwardEnd.vue') },
      { path: '/' + mpath[33], name: 'PatentEnd', component: () => import(/* webpackChunkName: "about" */ '../views/kyproject/PatentEnd.vue') },
      { path: '/' + mpath[9], name: 'FirstExam', component: () => import(/* webpackChunkName: "about" */ '../views/projectexam/FirstExam.vue') },
      { path: '/' + mpath[6], name: 'SecondExam', component: () => import(/* webpackChunkName: "about" */ '../views/projectexam/SecondExam.vue') },
      { path: '/' + mpath[10], name: 'ArticleExam', component: () => import(/* webpackChunkName: "about" */ '../views/projectexam/ArticleExam.vue') },
      { path: '/' + mpath[11], name: 'RewardExam', component: () => import(/* webpackChunkName: "about" */ '../views/projectexam/RewardExam.vue') },
      { path: '/' + mpath[12], name: 'PatentExam', component: () => import(/* webpackChunkName: "about" */ '../views/projectexam/PatentExam.vue') },
      { path: '/' + mpath[15], component: () => import(/* webpackChunkName: "about" */ '../views/scientificexam/ExamScheme.vue') },
      { path: '/' + mpath[16], component: () => import(/* webpackChunkName: "about" */ '../views/scientificexam/ExamResult.vue') },
      { path: '/' + mpath[18], component: () => import(/* webpackChunkName: "about" */ '../views/scientificachieve/ArticleAchieve.vue') },
      { path: '/' + mpath[19], component: () => import(/* webpackChunkName: "about" */ '../views/scientificachieve/RewardAchieve.vue') },
      { path: '/' + mpath[20], component: () => import(/* webpackChunkName: "about" */ '../views/scientificachieve/PatentAchieve.vue') },
      { path: '/' + mpath[22], component: () => import(/* webpackChunkName: "about" */ '../views/systemmanage/User.vue') },
      { path: '/' + mpath[23], component: () => import(/* webpackChunkName: "about" */ '../views/systemmanage/Permission.vue') },
      { path: '/' + mpath[24], component: () => import(/* webpackChunkName: "about" */ '../views/systemmanage/Role.vue') },
      { path: '/' + mpath[25], component: () => import(/* webpackChunkName: "about" */ '../views/systemmanage/Dictionary.vue') },
      { path: '/' + mpath[26], name: 'ProjectDetail', component: () => import(/* webpackChunkName: "about" */ '../views/projectexam/ProjectDetail.vue') },
      { path: '/' + mpath[34], name: 'ArticleDetail', component: () => import(/* webpackChunkName: "about" */ '../views/projectexam/ArticleDetail.vue') },
      // { path: '/' + mpath[35], component: () => import(/* webpackChunkName: "about" */ '../views/projectexam/PatentDetail.vue') },
      // { path: '/' + mpath[36], component: () => import(/* webpackChunkName: "about" */ '../views/projectexam/Rewarddetail.vue') },
      { path: '/' + mpath[37], component: () => import(/* webpackChunkName: "about" */ '../views/projectexam/RewardDetail.vue') },
      { path: '/' + mpath[43], component: () => import(/* webpackChunkName: "about" */ '../components/error/error403.vue') },
      { path: '/' + mpath[44], component: () => import(/* webpackChunkName: "about" */ '../components/error/error404.vue') },
      { path: '/' + mpath[45], component: () => import(/* webpackChunkName: "about" */ '../components/error/error500.vue') },
      { path: '/' + mpath[27], component: () => import(/* webpackChunkName: "about" */ '../views/systemmanage/Log.vue') },
      { path: '/' + mpath[38], component: () => import(/* webpackChunkName: "about" */ '../views//Center.vue') }
    ]
  }
]

const router = new VueRouter({
  routes
})

NProgress.configure({ showSpinner: true })
// 在路由跳转前用NProgress.start()标记下进度条开始
router.beforeEach((to, from, next) => {
  NProgress.start()
  next()
})

// 在路由跳转后用NProgress.done()标记下结束
router.afterEach(() => {
  NProgress.done()
})
export default router
